'''
DCT-Net人像卡通化-扩散模型-漫画
'''

import cv2
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks


img_cartoon = pipeline(Tasks.image_portrait_stylization, 
                       model='damo/cv_unet_person-image-cartoon-sd-illustration_compound-models', model_revision='v1.0.1')
# 图像本地路径
#img_path = 'input.png'
# 图像url链接
img_path = 'https://modelscope.oss-cn-beijing.aliyuncs.com/demo/image-cartoon/cartoon.png'
result = img_cartoon(img_path)

cv2.imwrite('result.png', result[OutputKeys.OUTPUT_IMG])
print('finished!')